<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "stock_product".
 *
 * @property int $id
 * @property string $title 产品名称
 * @property string $spec 规格描述
 * @property string $unit 单位
 * @property string $pic 展示图片
 * @property string $cost_price 成本价
 * @property string $sale_price 销售价
 * @property string $purchase_price 采购价
 * @property string $memo 备注
 * @property string $created_time 创建时间
 * @property string $updated_time 更新时间
 * @property int $state 1正常0不显示
 */
class StockProduct extends \yii\db\ActiveRecord
{

    // 产品状态
    const STATE_VALID = 1;
    const STATE_INVALID = 0;

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'stock_product';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['uid','tally_id'], 'integer'],
            [['cost_price', 'sale_price', 'purchase_price'], 'number'],
            [['sale_price', 'purchase_price'], 'required'],
            [['created_time', 'updated_time'], 'safe'],
            [['state'], 'integer'],
            [['title', 'spec', 'pic', 'memo'], 'string', 'max' => 255],
            [['unit'], 'string', 'max' => 30],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => 'Title',
            'spec' => 'Spec',
            'unit' => 'Unit',
            'pic' => 'Pic',
            'cost_price' => 'Cost Price',
            'sale_price' => 'Sale Price',
            'purchase_price' => 'Purchase Price',
            'memo' => 'Memo',
            'created_time' => 'Created Time',
            'updated_time' => 'Updated Time',
            'state' => 'State',
        ];
    }
}
